Imports HtmlAgilityPack
Imports System.Net

Module Module1
    Public Sub Main()
        Dim wc As New WebClient()
        wc.Proxy = New WebProxy("inetprox", 8080)
        wc.Credentials = New NetworkCredential("testserver", "strpdsql", "labattsa")

        Dim document As New HtmlDocument()
        document.LoadHtml(wc.DownloadString("http://nsford.com/San-Antonio/For-Sale/Used/?PageSize=100"))
        
        Dim numPages As Integer = GetPageCount(document)

        For pageIndex As Integer = 1 To numPages
            Console.WriteLine(String.Format("***** Page {0} *****", pageIndex))

            document.LoadHtml(wc.DownloadString(String.Format("http://nsford.com/San-Antonio/For-Sale/Used/?PageSize=100&Page={0}", pageIndex)))
            Dim pageInventoryNodes As HtmlNodeCollection = SelectInventoryNodes(document)

            For inventoryIndex As Integer = 0 To pageInventoryNodes.Count - 1
                Dim inventoryNode As HtmlNode = pageInventoryNodes.Item(inventoryIndex)

                Dim dealerId As String = inventoryNode.SelectSingleNode(".//input[@class='vehicle-dealerid']").GetAttributeValue("value", String.Empty)
                Dim make As String = inventoryNode.SelectSingleNode(".//input[@class='vehicle-make']").GetAttributeValue("value", String.Empty)
                Dim model As String = inventoryNode.SelectSingleNode(".//input[@class='vehicle-model']").GetAttributeValue("value", String.Empty)
                Dim year As String = inventoryNode.SelectSingleNode(".//input[@class='vehicle-year']").GetAttributeValue("value", String.Empty)

                Dim price As Integer = 0
                Dim priceNode As HtmlNode = inventoryNode.SelectSingleNode(".//dd[@class='vehicle-price-default-price']")
                If priceNode IsNot Nothing
                    price = CInt(priceNode.InnerText.Replace("*", String.Empty))
                End If

                Dim vin As String = inventoryNode.SelectSingleNode(".//input[@class='vehicle-vin']").GetAttributeValue("value", String.Empty)

                Console.WriteLine(String.Format("{0} {1} {2} - {3}", year, make, model, If(price = 0, "Call for Price", price.ToString("C"))))
            Next
        Next
    End Sub

    Private Function GetPageCount(ByVal document As HtmlDocument) As Integer
        Dim numPages As Integer = 0

        Dim pageCountNodes As HtmlNodeCollection = document.DocumentNode.SelectNodes("//span[@class='page-count']/span")
        If pageCountNodes.Count > 0
            numPages = pageCountNodes.Item(0).InnerHtml
        End If

        Return numPages
    End Function

    Private Function SelectInventoryNodes(ByVal document As HtmlDocument) As HtmlNodeCollection
        Return document.DocumentNode.SelectNodes("//ul[@class='inventory-list']/li")
    End Function
End Module